<template>
  <div class="adminHandle" >
    <h2>第{{ selectyear }}学年成绩查询</h2>
    <div style="padding-bottom: 10px">
      <el-select v-model="selectyear" placeholder="请选择">
        <el-option
          v-for="item in whichyear"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </div>
    <div class="tablelist">
      <template>
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            prop="stucid"
            label="课程名称"
            width="300">
          </el-table-column>
          <el-table-column
            prop="tid"
            label="教师名称"
            width="300">
          </el-table-column>
          <el-table-column
            prop="usualscore"
            label="平时成绩">
          </el-table-column>
          <el-table-column
            prop="finalscore"
            label="总成绩">
          </el-table-column>
        </el-table>
      </template>
    </div>
  </div>
</template>


<script>
  import axios from 'axios';

export default {
  name:"StudentScoreInfo",
  data() {
    return {
      selectyear: 1,
      whichyear: [{value:1,label:"第一学年"},
                  {value:2,label:"第二学年"},
                  {value:3,label:"第三学年"},
                  {value:4,label:"第四学年"},],
      tableData: []
    }
  },
  mounted() {
    this.ip = localStorage.getItem('ip');
    this.token = sessionStorage.getItem('token');

    axios.defaults.headers.common["token"] = this.token;
    axios.get((this.ip + '/score/')).then((response)=>{
      console.log(response)
      console.log(response.data)
      for (let i=0;i<response.data.length;i++){
        this.tableData.push({
          stucid:response.data[i].courseName,
          tid:response.data[i].teacherName,
          usualscore:response.data[i].usualScore,
          finalscore: response.data[i].finalScore,
        })
      }
    }).catch(function (error) {
      console.log(error);
    });


  }
}
</script>

<style scoped>
.adminHandle{
  width: 100%;
  padding: 5px 10px 0 10px;
  margin: 20px 100px 0 100px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3);

}
</style>
